home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: Q about the float point format......
- Date: 19 Mar 1996 07:40 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <19MAR199607404893@erich.triumf.ca>
- References: <s3032089.15.314E68DD@sparc13.ncu.edu.tw>
- NNTP-Posting-Host: erich.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <s3032089.15.314E68DD@sparc13.ncu.edu.tw>, s3032089@sparc13.ncu.edu.tw (Alexander PeaceLand) writes...
- >
- > Could I dynamicly set the digits after the float POINT?
- >
- > In other word... I use printf to print the float point number
- > like 123.456789 but in the other time i only
- > want to print 123.456 or 123.4
- > How shall I do? Thanks! :)
-
- Read the printf() man pages about width and precision specifiers.
- Try something like:
- float f = 123.45678;
- printf("%6.2f", f);
- Should print 123.46
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
-
-